<?xml version="1.0" encoding="UTF-8"?><d:tdl xmlns="http://www.w3.org/1999/xhtml" xmlns:b="http://www.backbase.com/2006/btl" xmlns:bb="http://www.backbase.com/2006/client"  xmlns:d="http://www.backbase.com/2006/tdl" >

	<d:namespace name="http://www.backbase.com/2006/btl">

		<d:uses element="formField" src="../formField/formField.xml"/>

		<d:element name="formList" extends="b:formField" abstract="true">
			

			<d:property name="multiple">
				
				<d:getter type="text/javascript"><![CDATA[return false;]]></d:getter>
			</d:property>

			<d:property name="options">
				
				<d:getter type="text/javascript"><![CDATA[
					if (this._._options)
						return this._._options;

					var aChildren = this.getProperty('childNodes');
					var aReturn = [];

					for (var i = 0, iMax = aChildren.length ; iMax > i ; i++ ){
						if (aChildren[i] && bb.instanceOf(aChildren[i], 'http://www.backbase.com/2006/btl', 'formListOption'))
							aReturn[aReturn.length] = aChildren[i];
					}
					this._._options = aReturn;
					return aReturn;
				]]></d:getter>
			</d:property>

			<d:property name="selectedIndex">
				
				<d:getter type="text/javascript"><![CDATA[
					// by default, the index is -1, unless an option is selected;
					var iSelectedIndex = -1;
					var aOptions = this.getProperty('options');
					for (var i = 0, iMax = aOptions.length; iMax > i; i++) {
						if (aOptions[i].getProperty('selected')) {
							iSelectedIndex = i;
							break
						}
					}
					return iSelectedIndex;
				]]></d:getter>
			</d:property>

			<d:handler event="DOMNodeInserted" type="text/javascript"><![CDATA[
				// reset options cache when an option is added
				if (event.relatedNode == this && bb.instanceOf(event.target, 'http://www.backbase.com/2006/btl', 'formListOption')) {
					this._._options = null;
				}
			]]></d:handler>

			<d:handler event="DOMNodeRemoved" type="text/javascript"><![CDATA[
				// reset options cache when an option is removed
				if (event.relatedNode == this && bb.instanceOf(event.target, 'http://www.backbase.com/2006/btl', 'formListOption')) {
					this._._options = null;
				}
			]]></d:handler>
		</d:element>

		<!-- TODO: change documentation -->
		<d:element name="formListOption" extends="b:element" abstract="true">
			

			

			

			<d:attribute name="selected">
				
				<!-- It is used only for initial value of a control(related to form's reset method).
					In other case always use 'selected' property. -->
			</d:attribute>

			<d:attribute name="value">
				
			</d:attribute>

			<d:property name="selected">
				
				<d:getter type="text/javascript"><![CDATA[
					// if no value has been defined, store the property and return what has been set in the attribute
					if(this._['_selected'] === undefined){
						var sSelected = this.getAttribute('selected');
						this._['_selected'] = btl.isTrueValue('selected', sSelected);
					}
					return this._['_selected'];
				]]></d:getter>
				<d:setter type="text/javascript"><![CDATA[
					value = value ? true : false;
					// determining type of event
					var sEvent = value ? "select" : "deselect";
					// saving old value
					var bOldValue = this._['_selected'];
					// putting new value
					this._['_selected'] = value;
					if(bOldValue != this._['_selected'])
						bb.command.fireEvent(this, sEvent, false, false);
				]]></d:setter>
			</d:property>

			<d:property name="text">
				
				<d:getter type="text/javascript"><![CDATA[
					var sText;
					if (this.viewNode) {
						sText = bb.browser.ie ? this.viewNode.innerText : this.viewNode.textContent;
					} else {
						sText = this.getProperty('textContent');
					}
					return bb.string.trim(sText);
				]]></d:getter>
			</d:property>

			<d:property name="value">
				
				<d:getter type="text/javascript"><![CDATA[
					var sValue;
					if (this._['_value'] === undefined) {
						if (this.hasAttribute('value'))
							sValue = this.getAttribute('value');
						else
							sValue = this.getProperty('text');
						this._['_value'] = sValue;
					}
					return this._['_value'];
				]]></d:getter>
			</d:property>
		</d:element>
	</d:namespace>
</d:tdl>